package com.more.offer.designpatterns.composition;

/**
 * @author pinoc
 * @date 2021/10/28
 * @description
 */
public class FinanceDepartment extends Department {
	public FinanceDepartment() {
	}

	public FinanceDepartment(String name) {
		super(name);
	}

	@Override
	public void addDept(Department dept) {

	}

	@Override
	public void showDept(int depth) {
		StringBuilder sb = new StringBuilder("");
		for (int i = 0; i < depth; i++) {
			sb.append("--");
		}
		System.out.println(new String(sb) + this.getName());
	}

	public static void main(String[] args) {
		Department root = new RootDepartment();
		root.setName("北京总公司");
		root.addDept(new HrDepartment("总公司人力资源部"));
		root.addDept(new FinanceDepartment("总公司财务部"));

		Department shandongCom = new RootDepartment("山东分公司");
		shandongCom.addDept(new HrDepartment("山东分公司人力资源部"));
		shandongCom.addDept(new FinanceDepartment("山东分公司账务部"));

		Department zaozhuangCom = new RootDepartment("枣庄办事处");
		zaozhuangCom.addDept(new FinanceDepartment("枣庄办事处财务部"));
		zaozhuangCom.addDept(new HrDepartment("枣庄办事处人力资源部"));

		Department jinanCom = new RootDepartment("济南办事处");
		jinanCom.addDept(new FinanceDepartment("济南办事处财务部"));
		jinanCom.addDept(new HrDepartment("济南办事处人力资源部"));

		shandongCom.addDept(jinanCom);
		shandongCom.addDept(zaozhuangCom);

		Department huadongCom = new RootDepartment("上海华东分公司");
		huadongCom.addDept(new HrDepartment("上海华东分公司人力资源部"));
		huadongCom.addDept(new FinanceDepartment("上海华东分公司账务部"));

		Department hangzhouCom = new RootDepartment("杭州办事处");
		hangzhouCom.addDept(new FinanceDepartment("杭州办事处财务部"));
		hangzhouCom.addDept(new HrDepartment("杭州办事处人力资源部"));

		Department nanjingCom = new RootDepartment("南京办事处");
		nanjingCom.addDept(new FinanceDepartment("南京办事处财务部"));
		nanjingCom.addDept(new HrDepartment("南京办事处人力资源部"));

		huadongCom.addDept(hangzhouCom);
		huadongCom.addDept(nanjingCom);

		root.addDept(shandongCom);
		root.addDept(huadongCom);

		root.showDept(12);
	}

}
